﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "GbmpUiPlatform.h"
#include "IPlane.h"
#include "NdbObjectSchematic.h"
#include "DbDataSchema.h"
#include "IElementParametersCustomizer.h"
#include "IElementUiManipulatorComponent.h"
#include "IElementViewSpecificShapeComponent.h"
#include "IElementShapeHandleBehavior.h"
#include "IElementDeletionComponent.h"
#include "IElementTransformationComponent.h"
#include "WeakPtr.h"
#include "IElement.h"
#include "IElementCopyPasteComponent.h"

namespace gcmp {
    class IElement;
    class IDocument;
    class IElementShapeHandle;

    class ClipBoardShapeHandleBehavior :public NdbObjectSchematic, public IElementShapeHandleBehavior
    {
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(gcmp, ClipBoardShapeHandleBehavior, gcmp::NdbObjectSchematic, CE0DAEAC - 0B80 - 46FE - 9A86 - 08F4F5959221, gbmpuiplatform, gcmp::IElementShapeHandleBehavior)
            DATA(IDocument*, Document)
            DATA(Vector3d, InserPt)
            DATA(ElementId, ElementShapeHandleId)
        DBOBJECT_DATA_END
    public:
        ClipBoardShapeHandleBehavior(IDocument* pDoc, const Vector3d& inserPt);
        ~ClipBoardShapeHandleBehavior();

        //属性存取
    public:
        IDocument* GetDocument() const override { return GetDocument__(); }
        void SetDocument(const IDocument* pDoc) { SetDocument__(pDoc); }

        ElementId GetElementShapeHandleId() const override { return GetElementShapeHandleId__(); }
        void SetElementShapeHandleId(const ElementId& id) override { return SetElementShapeHandleId__(id); }
        IElementShapeHandle* GetElementShapeHandle() const;

        //重写IElementShapeHandleBehavior方法
    public:
        virtual ElementId GetModelViewId() const override { return ElementId::InvalidID; };
        virtual bool Translate(const gcmp::IElementMoveContext& moveContext) override { return false; }
        virtual void GetCalculators(ICalculatorCollection* calculators) const override;
        virtual void UpdatePosition() override {};
        virtual void ReportParents(IElementParentReporter& reporter) const override {};
        virtual void GetNearestPoint(Vector3d& nearPoint) const override {};
        virtual gcmp::OwnerPtr<gcmp::IGraphicsElementShape> CreateGrahicsElementShapeInModelView(const gcmp::IModelView* pModelView) const override;
        virtual bool FinishEditing() override { return false; }

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override
        {
            return nullptr;
        }

    public:
        virtual bool GetHandleCommandString(const IObject* commandEnvironment, std::wstring& commandStr, gcmp::CommandParameters& cmdParams) const override;
        virtual void UpdatePositionIndexInMasterElement() override;
    };
    
}// namespace gcmp

